	import java.util.*;
	
	public class TraderHash extends HashMap<String, String> {
		
		
		void createEntry( String user, String traderdata )
		{
			put(user, traderdata);
		}
		
		void setResource(String user, String ore, int amt){
			//get user resrouces and amount
			String data = get(user);
			if(data == null)
				return;
			
  //user data is in a string with ";" separating the resource types. ex:  "cash:120;silver:200"
			String vals[] = data.split(";");
			
			boolean found = false;
			StringBuilder sbuild = new StringBuilder();
			for(int i = 0; i < vals.length; i++){
        //split the resource type and amount ex:  "silver:200"
        String tmpVals[] = vals[i].split(":");
        //if the resource is found, add the amount to the current amount and append to the user data
        if(!found && tmpVals[0].equals(ore)){
					vals[i] = tmpVals[0] + ":" + amt + ";";
					found = true; 
				}
				sbuild.append(vals[i]);
			}
			//if the user does not currently have the resource, add it to the user data
			if(!found){
				sbuild.append(ore+":"+amt);
			}
			put(user, sbuild.toString());
		}
		
		//get resource Amt
		int getResourceAmt(String user, String ore ){
			String data = get(user);
			if(data == null)
				return -1;
			
			String vals[] = data.split(";");
			
			int amt = 0;
			for(int i = 0; i < vals.length; i++){
				String tmpVals[] = vals[i].split(":");
           //get resource amount for the specified resource
				if(tmpVals[0].equals(ore)){
					amt = Integer.parseInt(tmpVals[1]);
					break;
				}
			}
			
			return amt;
			
		}
        //get all data for a specified user:  String in format "cash:200;gold:212"
		String getUserInfo(String user){
			return get(user);
		}		
	}